package com.msb.controller;

import com.msb.pojo.Book;
import com.msb.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
public class BookController {
    //创建业务层对象（供控制层使用）
    @Autowired
    private BookService bookService;
    @RequestMapping("/findbooks")
    @ResponseBody
    public String findbooks(){
        //把业务层的获取到的数据库的东西取出来
        List list = bookService.findAllbooks();
        String s="";
        for (int i=0;i<=list.size()-1;i++){
            Book books = (Book)list.get(i);
            s+=books.getName();
            s+=books.getAuthor();
        }
        return s;
    }
}
